import Vue from "vue";
import Vuex from 'vuex';

import user from  './modules/user';
import app from './modules/app.js';

Vue.use(Vuex);
import createPersistedState from 'vuex-persistedstate'
import Cookies from 'js-cookie';

const store = new Vuex.Store({
	state: {},
	mutations: {
		logout (state) {
			Cookies.remove('userInfo');
			localStorage.clear();
			state.user.userInfo.userId = '';
			state.user.userInfo.username = '';
			state.user.userInfo.accessToken = '';
			state.app.menuList = [];
		}
	},
	actions: {},
	modules: {
		user,
		app
	},
	plugins: [createPersistedState()]
});

export default store;